package com.ruibang.glass.produce.component.job;

import com.ruibang.glass.produce.service.ClassReportService;
import com.teaming.cloud.framework2.elastic.job3.annotation.ElasticJobScheduler;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-05-06  17:41
 * @Description: TODO:配料班报填写任务   每天下午5点执行
 * @Version: 1.0
 */

@Slf4j
@ElasticJobScheduler(cron = "0 5 17 * * ?")
//@ElasticJobScheduler(cron = "5 * * * * ?")
@Component
public class ClassReportTask implements SimpleJob {

    @Autowired
    private ClassReportService classReportService;

    @Override
    public void execute(ShardingContext shardingContext) {
        //获取最大班报最大时间
        LocalDate date = classReportService.getMaxDate();
        if (date != null) {
            classReportService.executeClassReportTask(date);
        }
    }

}
